package com.itheima.test6;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author:gy
 * @Date: 2025/09/04 10:09
 * @Description:
 */
public class ServerDemo {
    public static void main(String[] args) throws Exception {
        //创建服务端Socket对象
        ServerSocket ss = new ServerSocket(10000);
        //一直监听,有没有人给我发信息
        Socket socket = ss.accept();
        System.out.println("你好");
        //如果有人给我发信息  读取里面的信息
        InputStream is = socket.getInputStream();
        int b;
        while ((b = is.read()) != -1) {
            System.out.print((char) b);
        }
        System.out.println("hello");
        is.close();
        ss.close();
    }
}
